package org.example;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@SpringBootApplication  // 启动注解，包含 @Configuration @ComponentScan @EnableAutoConfiguration
public class App 
{
    @Autowired
    private TimePrinterTask timePrinterTask;

    @Autowired
    private ThreadPoolTaskExecutor myThreadPool;

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    public void run(String... args) throws Exception {
        System.out.println("🚀 应用启动中...提交任务到线程池");

        // 提交任务到线程池执行
        myThreadPool.submit(timePrinterTask);

        // 等待任务完成（非必需，只是为了看到输出完整）
        timePrinterTask.await();

        System.out.println("🔚 主程序即将退出。");
    }
}